//处理模型
const {
    successModel,
    failModel
} = require('../model/responseModel')


const {
    login,
    // verifyToken,
    // deleteToken,
} = require('../controller/login')

const {verifyToken}  = require('../utils')

//处理用户相关的路由
const handleLoginRoute = (req, res) => {
    //定义处理路由的逻辑
    const method = req.method;
    console.log(req.query, req.path);
    switch (method) {

        case 'POST': {
            if (req.path === '/login') {
                //登录
                console.log(req.body, 'login');
                return login(req.body).then((data) => {
                    if (data)
                        return new successModel(data)
                    return new failModel('登录失败')
                })
            }

            else{
                return false;
            }
        };

    case 'GET': {

    };
    default: {
        return false;
    }
    }

}

module.exports = handleLoginRoute